package com.baidu.mapapi;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import java.lang.reflect.Method;
import java.nio.ShortBuffer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class a extends View
{
  private static Method J = null;
  private static Method K = null;
  private static Method L = null;
  private static Bitmap h = null;
  private static ShortBuffer i = null;
  private static short[] j = null;
  private static int k = 0;
  private static int l = 0;
  private static int m = 0;
  private float A;
  private float B;
  private float C;
  private float D;
  private int E = 0;
  private int F = 0;
  private boolean G = false;
  private int H = 0;
  private Paint I = new Paint();
  private MapView.a M = MapView.a.b;
  boolean a = false;
  int b = 0;
  int c = 0;
  int d = 0;
  double e = 1.0D;
  int f = 0;
  int g = 0;
  private int n = 0;
  private int o = 0;
  private int p = 0;
  private int q = 0;
  private MapView r = null;
  private List<Overlay> s = new ArrayList();
  private boolean t = false;
  private boolean u = true;
  private long v = 0L;
  private long w = 0L;
  private long x = 0L;
  private float y;
  private float z;

  public a(Context paramContext, MapView paramMapView)
  {
    super(paramContext);
    this.r = paramMapView;
    this.I.setColor(-7829368);
    this.I.setStyle(Paint.Style.STROKE);
  }

  private void c(Canvas paramCanvas)
  {
  }

  private void d(Canvas paramCanvas)
  {
    long l1 = 1000L * System.nanoTime() / 1000000000L;
    Iterator localIterator = this.s.iterator();
    while (localIterator.hasNext())
      ((Overlay)localIterator.next()).draw(paramCanvas, this.r, false, l1);
  }

  void a()
  {
    if ((h != null) && (h.isRecycled()))
      h.recycle();
    l = 0;
    m = 0;
    h = null;
  }

  void a(int paramInt)
  {
    this.H = paramInt;
  }

  public void a(int paramInt1, int paramInt2, int paramInt3)
  {
    this.F = (paramInt1 + this.F);
    this.E = 3;
    if ((paramInt2 == 0) && (paramInt3 == 0))
      this.f = (h.getWidth() / 2);
    for (this.g = (h.getHeight() / 2); ; this.g = paramInt3)
    {
      Mj.o = 1;
      invalidate();
      return;
      this.f = paramInt2;
    }
  }

  public void a(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    if ((paramInt4 <= 0) || (paramInt3 <= 0));
    int i1;
    int i2;
    do
    {
      return;
      i1 = 4 * ((paramInt3 + 3) / 4);
      i2 = 4 * ((paramInt4 + 3) / 4);
    }
    while ((l == i1) && (m == i2));
    Iterator localIterator = this.s.iterator();
    while (localIterator.hasNext())
      ((Overlay)localIterator.next()).a(paramInt1, paramInt2, i1, i2);
    int i3 = 2 * (i1 * i2);
    if (i3 > k)
    {
      j = new short[i3];
      i = ShortBuffer.allocate(i3);
      k = i3;
    }
    h = Bitmap.createBitmap(i1, i2, Bitmap.Config.RGB_565);
    Mj.o = 1;
    Mj.renderUpdateScreen(j, i1, i2);
    l = i1;
    m = i2;
  }

  protected void a(Canvas paramCanvas)
  {
    paramCanvas.drawRGB(192, 192, 192);
    Matrix localMatrix = new Matrix();
    if ((this.H != 1) && (this.e != 1.0D))
    {
      double d1 = Math.abs(this.e);
      localMatrix.postScale((float)d1, (float)d1, this.f, this.g);
      localMatrix.postTranslate(this.c, this.d);
      paramCanvas.drawBitmap(h, localMatrix, null);
      return;
    }
    paramCanvas.drawBitmap(h, this.c, this.d, null);
  }

  void a(boolean paramBoolean)
  {
    this.u = paramBoolean;
  }

  void a(boolean paramBoolean, int paramInt, Rect paramRect)
  {
    super.onFocusChanged(paramBoolean, paramInt, paramRect);
  }

  boolean a(int paramInt, KeyEvent paramKeyEvent)
  {
    int i1 = -1 + this.s.size();
    boolean bool = false;
    for (int i2 = i1; ; i2--)
      if (i2 >= 0)
      {
        bool = ((Overlay)this.s.get(i2)).onKeyDown(paramInt, paramKeyEvent, this.r);
        if (!bool);
      }
      else
      {
        return bool;
      }
  }

  boolean a(MotionEvent paramMotionEvent)
  {
    int i1;
    if (Integer.parseInt(Build.VERSION.SDK) <= 4)
    {
      i1 = 1;
      if (i1 != 2)
        break label654;
    }
    while (true)
    {
      try
      {
        while (true)
        {
          Method localMethod1 = L;
          Object[] arrayOfObject1 = new Object[1];
          arrayOfObject1[0] = Integer.valueOf(0);
          this.y = ((Float)localMethod1.invoke(paramMotionEvent, arrayOfObject1)).floatValue();
          Method localMethod2 = K;
          Object[] arrayOfObject2 = new Object[1];
          arrayOfObject2[0] = Integer.valueOf(0);
          this.z = ((Float)localMethod2.invoke(paramMotionEvent, arrayOfObject2)).floatValue();
          Method localMethod3 = L;
          Object[] arrayOfObject3 = new Object[1];
          arrayOfObject3[0] = Integer.valueOf(1);
          this.A = ((Float)localMethod3.invoke(paramMotionEvent, arrayOfObject3)).floatValue();
          Method localMethod4 = K;
          Object[] arrayOfObject4 = new Object[1];
          arrayOfObject4[0] = Integer.valueOf(1);
          this.B = ((Float)localMethod4.invoke(paramMotionEvent, arrayOfObject4)).floatValue();
          this.D = ((float)Math.sqrt((this.y - this.A) * (this.y - this.A) + (this.z - this.B) * (this.z - this.B)) / 2.0F);
          if (this.E == 0)
          {
            if (this.D > 30.0F * Mj.j)
            {
              this.t = false;
              this.f = ((int)((this.y + this.A) / 2.0F - this.c));
              this.g = ((int)((this.z + this.B) / 2.0F - this.d));
              this.C = this.D;
              this.E = 1;
            }
            if (this.E == 0)
              break label674;
            return false;
            try
            {
              if (J == null)
              {
                Class localClass = Class.forName("android.view.MotionEvent");
                J = localClass.getMethod("getPointerCount", (Class[])null);
                Class[] arrayOfClass1 = new Class[1];
                arrayOfClass1[0] = Integer.TYPE;
                L = localClass.getMethod("getX", arrayOfClass1);
                Class[] arrayOfClass2 = new Class[1];
                arrayOfClass2[0] = Integer.TYPE;
                K = localClass.getMethod("getY", arrayOfClass2);
              }
              int i11 = ((Integer)J.invoke(paramMotionEvent, new Object[0])).intValue();
              i1 = i11;
            }
            catch (Exception localException1)
            {
              localException1.printStackTrace();
              i1 = 0;
            }
          }
        }
      }
      catch (Exception localException2)
      {
        localException2.printStackTrace();
        continue;
        if (this.H == 1)
        {
          double d1 = Math.log(this.D / this.C) / Math.log(3.0D);
          if (d1 >= 0.0D)
          {
            i8 = (int)(d1 + 0.5D);
            if (i8 == 0)
              continue;
            this.C = this.D;
            Bundle localBundle = new Bundle();
            localBundle.putInt("act", 1001);
            localBundle.putInt("opt", 10020600);
            localBundle.putInt("level", i8);
            localBundle.putInt("x", this.f);
            localBundle.putInt("y", this.g);
            int i9 = this.f + this.c - l / 2;
            int i10 = this.g + this.d - m / 2;
            localBundle.putInt("dx", i9);
            localBundle.putInt("dy", i10);
            Mj.sendBundle(localBundle);
            continue;
          }
          int i8 = (int)(d1 - 0.5D);
          continue;
        }
        this.e = (this.D / this.C);
        invalidate();
        continue;
      }
      label654: if (this.E == 1)
      {
        this.E = 2;
        invalidate();
      }
    }
    label674: for (int i2 = -1 + this.s.size(); i2 >= 0; i2--)
      if (((Overlay)this.s.get(i2)).onTouchEvent(paramMotionEvent, this.r))
        return true;
    switch (paramMotionEvent.getAction())
    {
    default:
      return false;
    case 0:
      this.n = ((int)paramMotionEvent.getX());
      this.o = ((int)paramMotionEvent.getY());
      this.c = 0;
      this.d = 0;
      this.t = true;
      Mj.k = (int)paramMotionEvent.getX();
      Mj.l = (int)paramMotionEvent.getY();
      Mj.MapProc(4, (int)paramMotionEvent.getX(), (int)paramMotionEvent.getY());
    case 1:
    case 2:
    }
    while (true)
    {
      return true;
      if (!this.t)
        return true;
      this.t = false;
      if ((this.c != 0) || (this.d != 0))
      {
        this.c = 0;
        this.d = 0;
      }
      int i3 = (int)paramMotionEvent.getX();
      int i4 = (int)paramMotionEvent.getY();
      int i7;
      if (this.u)
      {
        i7 = (int)(50.0F * Mj.j);
        if ((this.x - this.w < 1000L) && (Math.abs(i3 - this.n) < i7) && (Math.abs(i4 - this.o) < i7))
          this.v = (1L + this.v);
        if (this.v == 1L)
          this.w = System.currentTimeMillis();
      }
      else
      {
        label965: int i5 = (int)(10.0F * Mj.j);
        if ((Math.abs(this.n - i3) < i5) && (Math.abs(this.o - i4) < i5))
        {
          i3 = this.n;
          i4 = this.o;
        }
        this.p = i3;
        this.q = i4;
        Mj.m = i3;
        Mj.n = i4;
        Mj.MapProc(5, i3, i4);
        if ((Math.abs(i3 - this.n) >= 20) || (Math.abs(i4 - this.o) >= 20))
          continue;
      }
      label1304: for (int i6 = -1 + this.s.size(); i6 >= 0; i6--)
      {
        Overlay localOverlay = (Overlay)this.s.get(i6);
        GeoPoint localGeoPoint = this.r.getProjection().fromPixels((int)paramMotionEvent.getX(), (int)paramMotionEvent.getY());
        if ((localOverlay instanceof ItemizedOverlay));
        for (boolean bool = ((ItemizedOverlay)localOverlay).onTap(localGeoPoint, this.r); ; bool = localOverlay.onTap(localGeoPoint, this.r))
        {
          if (!bool)
            break label1304;
          return true;
          if (this.v < 2L)
            break label965;
          this.x = System.currentTimeMillis();
          if ((this.x - this.w < 1000L) && (Math.abs(this.p - i3) < i7) && (Math.abs(this.q - i4) < i7))
          {
            if (this.r.getZoomLevel() < 18)
              a(1, i3, i4);
            this.v = 0L;
            this.w = 0L;
            this.x = 0L;
            break;
          }
          this.v = 0L;
          this.w = 0L;
          this.x = 0L;
          break label965;
        }
      }
      if (this.t == true)
      {
        this.c = ((int)paramMotionEvent.getX() - this.n);
        this.d = ((int)paramMotionEvent.getY() - this.o);
        invalidate();
        Mj.MapProc(3, (int)paramMotionEvent.getX(), (int)paramMotionEvent.getY());
      }
    }
  }

  protected void b(Canvas paramCanvas)
  {
    a(paramCanvas);
    if ((!this.G) && (this.e != 1.0D))
      return;
    switch (1.a[this.M.ordinal()])
    {
    default:
      c(paramCanvas);
      d(paramCanvas);
      return;
    case 1:
      d(paramCanvas);
      return;
    case 2:
      d(paramCanvas);
      c(paramCanvas);
      return;
    case 3:
    }
    c(paramCanvas);
    d(paramCanvas);
  }

  void b(boolean paramBoolean)
  {
    this.G = paramBoolean;
  }

  boolean b()
  {
    return this.u;
  }

  boolean b(int paramInt, KeyEvent paramKeyEvent)
  {
    int i1 = -1 + this.s.size();
    boolean bool = false;
    for (int i2 = i1; ; i2--)
      if (i2 >= 0)
      {
        bool = ((Overlay)this.s.get(i2)).onKeyUp(paramInt, paramKeyEvent, this.r);
        if (!bool);
      }
      else
      {
        return bool;
      }
  }

  boolean b(MotionEvent paramMotionEvent)
  {
    int i1 = -1 + this.s.size();
    boolean bool = false;
    for (int i2 = i1; ; i2--)
      if (i2 >= 0)
      {
        bool = ((Overlay)this.s.get(i2)).onTrackballEvent(paramMotionEvent, this.r);
        if (!bool);
      }
      else
      {
        return bool;
      }
  }

  public final List<Overlay> c()
  {
    return this.s;
  }

  boolean d()
  {
    for (int i1 = -1 + this.s.size(); i1 >= 0; i1--)
      if (((Overlay)this.s.get(i1) instanceof MyLocationOverlay))
        return true;
    return false;
  }

  protected void onDraw(Canvas paramCanvas)
  {
    this.r.e();
    switch (this.E)
    {
    default:
      b(paramCanvas);
      return;
    case 0:
      if ((j != null) && (this.a == true))
      {
        this.c = 0;
        this.d = 0;
        i.put(j);
        i.rewind();
        h.copyPixelsFromBuffer(i);
        this.a = false;
        this.e = 1.0D;
      }
      b(paramCanvas);
      return;
    case 1:
      if ((this.H == 1) && (j != null) && (this.a == true))
      {
        this.c = 0;
        this.d = 0;
        i.put(j);
        i.rewind();
        h.copyPixelsFromBuffer(i);
        this.a = false;
        this.e = 1.0D;
      }
      b(paramCanvas);
      return;
    case 2:
      if (this.H == 1)
      {
        this.E = 0;
        b(paramCanvas);
        return;
      }
      double d2 = Math.log(this.e) / Math.log(2.0D);
      int i1;
      int i2;
      double d3;
      if (d2 >= 0.0D)
      {
        i1 = (int)(0.5D + d2);
        i2 = (int)(10.0D * (i1 - d2));
        if (i2 == 0)
          break label323;
        if (i2 <= 0)
          break label307;
        d3 = d2 + 0.1D;
        (i2 - 1);
      }
      while (true)
      {
        this.e = Math.pow(2.0D, d3);
        b(paramCanvas);
        postInvalidate();
        return;
        i1 = (int)(d2 - 0.5D);
        break;
        label307: d3 = d2 - 0.1D;
        (i2 + 1);
      }
      label323: this.e = Math.pow(2.0D, i1);
      b(paramCanvas);
      if (d2 != 0.0D)
      {
        Bundle localBundle3 = new Bundle();
        localBundle3.putInt("act", 1001);
        localBundle3.putInt("opt", 10020600);
        localBundle3.putInt("level", i1);
        localBundle3.putInt("x", this.f);
        localBundle3.putInt("y", this.g);
        int i3 = this.f + this.c - l / 2;
        int i4 = this.g + this.d - m / 2;
        localBundle3.putInt("dx", i3);
        localBundle3.putInt("dy", i4);
        Mj.sendBundle(localBundle3);
      }
      this.E = 0;
      return;
    case 3:
    }
    if (this.H == 1)
    {
      b(paramCanvas);
      Bundle localBundle2 = new Bundle();
      localBundle2.putInt("act", 1001);
      localBundle2.putInt("opt", 10020600);
      localBundle2.putInt("level", this.F);
      localBundle2.putInt("x", this.f);
      localBundle2.putInt("y", this.g);
      localBundle2.putInt("dx", 0);
      localBundle2.putInt("dy", 0);
      Mj.sendBundle(localBundle2);
      this.E = 0;
      this.F = 0;
      return;
    }
    double d1 = Math.log(this.e) / Math.log(2.0D);
    if (this.F > 0)
      this.e += Math.pow(2.0D, (int)d1) / 10.0D;
    while (((this.e < 2 * this.F) && (this.e > 0.0D)) || ((this.F < 0) && (this.e > -1.0F / (2 * this.F))))
    {
      b(paramCanvas);
      postInvalidate();
      return;
      if (this.F < 0)
        this.e -= Math.pow(2.0D, (int)d1) / 20.0D;
    }
    b(paramCanvas);
    Bundle localBundle1 = new Bundle();
    localBundle1.putInt("act", 1001);
    localBundle1.putInt("opt", 10020600);
    localBundle1.putInt("level", this.F);
    localBundle1.putInt("x", this.f);
    localBundle1.putInt("y", this.g);
    localBundle1.putInt("dx", 0);
    localBundle1.putInt("dy", 0);
    Mj.sendBundle(localBundle1);
    this.E = 0;
    this.F = 0;
  }

  protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    super.onLayout(paramBoolean, paramInt1, paramInt2, paramInt3, paramInt4);
    a(paramInt1, paramInt2, paramInt3 - paramInt1, paramInt4 - paramInt2);
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.baidu.mapapi.a
 * JD-Core Version:    0.6.2
 */